Skip to content

fix(id): parse_wants refuses duplicate JSON keys (#7621) - #7623

Merged
dezren39 merged 1 commit into
mainfrom
creator-a/7621-wants-dupkeys
Nov 8, 2026
Merged

dezren39 merged 1 commit into
mainfrom
creator-a/7621-wants-dupkeys

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Fixes #7621

parse_wants (pkgs/id/crates/id-core/src/world_caps.rs) parsed a world program's wants document with a bare serde_json::from_str, so duplicate object keys collapsed last-wins before its checks ran — the one program-output gate in pkgs/id not migrated to the #6520 duplicate-key helper that parse_records already uses.

Verified pre-fix with a laptop probe over byte-identical copies of the real modules (~/git/fleet/probe-wants-dupkeys, main 0a27a7f): {"v":2,"v":1} passed the version check as v1; a 65-entry subscribe array hidden behind a duplicate key was never counted against MAX_WANTS_ENTRIES=64; a duplicate cap inside one request object silently replaced the requested capability. Controls (single-key bad version, single 65-entry array) were correctly rejected.

Change: parse through crate::json_unique::parse_json_without_duplicate_keys (same error context, "wants is not JSON"), plus rejects_duplicate_keys_at_any_depth covering duplicate v in both orders, a duplicate request cap, a duplicate inside request args, and the hidden over-limit subscribe array.

Verification: cargo test -p id-core on the branch — 329 passed, 0 failed (world_caps 30/30, including the new test); cargo fmt --check -p id-core clean. The sibling parse_surface gate was audited and deliberately left out of scope — rationale recorded on #7621.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The wants gate parsed with a bare serde_json::from_str, so duplicate object keys collapsed last-wins before the version check and the MAX_WANTS_ENTRIES bounds ran: {v:2,v:1} passed as v1, a 65-entry subscribe array hidden behind a duplicate key was never counted, and a duplicate cap inside one request object silently replaced the requested capability. Parse through the #6520 helper (parse_json_without_duplicate_keys), as parse_records already does, and pin it with rejects_duplicate_keys_at_any_depth. Probe-verified pre-fix against the real module (~/git/fleet/probe-wants-dupkeys); cargo test -p id-core 329 passed on the branch.
@dezren39
dezren39 requested a review from a team as a code owner November 8, 2026 10:04
@dezren39 dezren39 added kind/bug Something isn't working (prefixed form of the classic bug label) source/creator Filed by the new-issue-creator job app/id Package/app: id (pkgs/ or apps/ in this repo) labels Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a5186d0c-d715-4ff2-8e37-b74ebbf75cff
Commits

Reviewing files that changed from the base of the PR and between b6bd188 and 9e347a2.

Files selected for processing: 1

  • pkgs/id/crates/id-core/src/world_caps.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T10:05:31.191185Z 9e347a2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app/id Package/app: id (pkgs/ or apps/ in this repo) kind/bug Something isn't working (prefixed form of the classic bug label) source/creator Filed by the new-issue-creator job

Projects

None yet

1 participant